<template>
    <div>
        <main class="banxin">
    
    <div class="banner">
        <img src="@/assets/images/home/banner.png" alt="">
    </div>
  </main>
  <div class="content">
    <div class="content-main banxin">
        <!-- 精品 -->
        <div class="jinping">
            <section>
                <img src="@/assets/images/home/Recommend.png" alt="" class="jinimage">
                <span>精品推荐</span>
                <div class="more">
                    更多<img src="@/assets/images/home/Arrow.png" alt="">
                </div>
            </section>
            <ul class="list">
                <li v-for="item,index in jinping" :key="item.id">
                    <img :src="'http://sc.wolfcode.cn'+item.coverImg" alt="" class="image">
                    <div class="price">
                        <h4>{{ item.name }}</h4>
                        <p>{{item.coin}}积分</p>
                        <button @click="conversion(item.id)">立即兑换</button>
                    </div>
                    <img src="@/assets/images/home/new-j.png" alt="" class="hot">
                </li>
            </ul>
        </div>
        <!-- 热门兑换 -->
        <div class="jinping">
            <section>
                <img src="@/assets/images/home/hot.png" alt="" class="jinimage">
                <span>热门兑换</span>
                <div class="more">
                    更多<img src="@/assets/images/home/Arrow.png" alt="">
                </div>
            </section>
            <div class="add">
                <img src="@/assets/images/home/ad.png" alt="">
            </div>
            <ul class="list">
                <li v-for="item,index in hot">
                    <img :src="'http://sc.wolfcode.cn'+item.coverImg" alt="" class="image">
                    <div class="price">
                        <h4>{{ item.name }}</h4>
                        <p>{{item.coin}}积分</p>
                        <button @click="conversion(item.id)">立即兑换</button>
                    </div>
                    <img src="@/assets/images/home/hot-j.png" alt="" class="hot">
                </li>
            </ul>
        </div>
    </div>
    
  </div>
  <!-- 积分攻略 -->
  <div class="jifen banxin">
        <section>
            <img src="@/assets/images/home/integral.png" alt="" class="jinimage">
            <span>积分攻略</span>
        </section>
        <ul class="list">
            <li>
                <div class="price">
                    <h4>签到得鸡腿</h4>
                    <button>去签到</button>
                </div>
            </li>
            <li>
                <div class="price">
                    <h4>购课得鸡腿</h4>
                    <button>去购课</button>
                </div>
            </li>
            <li>
                <div class="price">
                    <h4>推荐得鸡腿</h4>
                    <button>去推荐</button>
                </div>
            </li>
            <li>
                <div class="price">
                    <h4>做任务得鸡腿</h4>
                    <button>做任务</button>
                </div>
            </li>
        </ul>
    </div>
  </div>
</template>

<script>
export default {
    data(){
        return {
            jinping:[],
            hot:[],
        }
    },
    methods:{
        conversion(id){
            this.$router.push({name:"detail",params:{id}})
        }
    },
    created(){
        this.$ajax.get("/products/recommend").then(res=>{
           this.jinping = res.data.data.records;
        })
        this.$ajax.get("/products/hot").then(res=>{
            this.hot = res.data.data.records;
        })
    }
}
</script>

<style lang="less" scoped>
    @import "@/assets/css/base.less";
    main{
        .banner{
            margin: 20px 0;
        }
    }
    .content{
        background-color: #F5F5F5;
        .content-main{
            padding: 50px 0;
            .jinping{
                section{
                    text-align: left;
                .jinimage{
                    width: 40px;
                    height: 36px;
                    display: inline-block;
                    vertical-align: bottom;
                }
                span{
                    padding: 0 10px;
                    font-size: 30px;
                    font-weight: bold;
                    color: #242B39;
                }
                .more{
                    float: right;
                    color: #666666;
                    font-size: 16px;
                    line-height: 36px;
                    img{
                        width: 14px;
                        height: 14px;
                        vertical-align: middle;
                    }
                }
            }
            .add{
                width: 100%;
                margin: 10px 0;
                background-color: #FFB089;
                height: 180px;
            }
            .list{
                    list-style: none;
                    width: 100%;
                    display: flex;
                    flex-wrap: wrap;
                    justify-content: space-between;
                    li{
                        width: 285px;
                        height: 412px;
                        background-color: #fff;
                        position: relative;
                        margin:20px 0;
                        transition: 0.5s;
                        &:hover{
                            transform: translateY(-20px);
                            .price button{
                                background-color: #0A328E;
                                color:#fff;
                                cursor: pointer;
                            }
                        }
                        .image{
                            width: 100%;
                            height: 250px;
                            display: block;
                            border: none;
                        }
                        .price{
                            width: 100%;
                            height: 162px;
                            display: flex;
                            flex-wrap: wrap;
                            flex-direction: column;
                            align-items: center;
                            justify-content: space-around;
                            h4{
                                color:#333;
                                font-size: 18px;
                                height: 18px;
                            }
                            p{
                                color: #FD604D;
                                height: 18px;
                            }
                            button{
                                color: #0A328E;
                                border: 1px solid #0A328E;
                                width: 100px;
                                height: 36px;
                                display: block;
                                background-color: #fff;
                                cursor: pointer;
                            }
                            
                        }
                        .hot{
                            width: 58px;
                            height: 58px;
                            position: absolute;
                            top: 0;
                            left: 0;
                        }
                    }
                }
            }
        }
        
    }
    .jifen{
            section{
                    text-align: left;
                .jinimage{
                    width: 40px;
                    height: 36px;
                    display: inline-block;
                    vertical-align: bottom;
                }
                span{
                    padding: 0 10px;
                    font-size: 30px;
                    font-weight: bold;
                    color: #242B39;
                }
            }
            .list{
                display: flex;
                list-style: none;
                justify-content: space-between;
                margin: 10px 0;
                li{
                    width: 285px;
                    height: 168px;
                    position: relative;
                    padding: 10px;
                    box-sizing: border-box;
                    transition:background-size 0.3s linear;
                    
                    .price{
                        position: absolute;
                        top:0;
                        bottom: 0;
                        margin: auto 0;
                        height: 60px;
                        h4{
                            font-size: 30px;
                            color: #fff;
                        }
                        button{
                            border: 1px solid #fff;
                            color: #fff;
                            width: 96px;
                            height: 27px;
                            margin-top: 10px;
                            background-color: rgba(0, 0, 0, 0);
                        }
                    }
                    &:nth-child(1){
                        background: url(../assets/images/home/integral-01.png);
                        background-size:100% 100% ;
                    }
                    &:nth-child(2){
                        background: url(../assets/images/home/integral-02.png);
                        background-size:100% 100% ;
                    }
                    &:nth-child(3){
                        background: url(../assets/images/home/integral-03.png);
                        background-size:100% 100% ;
                    }
                    &:nth-child(4){
                        background: url(../assets/images/home/integral-04.png);
                        background-size:100% 100% ;
                    }
                    &:hover{
                        background-size: 105% 105%;
                    }
                }
                
            }
        }
</style>